//
//  DesTableViewCell.m
//  HomeFurnishing
//
//  Created by dllo on 16/4/6.
//  Copyright © 2016年 YMing. All rights reserved.
//

#import "DesTableViewCell.h"

@implementation DesTableViewCell

-(void)dealloc
{
    [_userImg release];
    [_name release];
    [_sex release];
    [_address release];
    [_photoNum release];
    [_projectNum release];
    [_strategyNum release];
    [_firL release];
    [_secL release];
    [_thiL release];
    [_btnImg release];
    [_goldImg release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.userImg = [[UIImageView alloc] init];
        [self.contentView addSubview:self.userImg];
        [_userImg release];
        
        self.name = [[UILabel alloc] init];
        self.name.font = [UIFont systemFontOfSize:20];
        [self.contentView addSubview:self.name];
        self.name.numberOfLines = 0;
        [_name release];
        
        self.sex = [[UILabel alloc] init];
        [self.contentView addSubview:self.sex];
        [_sex release];
        
        self.address = [[UILabel alloc] init];
        [self.contentView addSubview:self.address];
        [_address release];
        
        self.projectNum = [[UILabel alloc] init];
        self.projectNum.textColor = [UIColor blueColor];
        [self.contentView addSubview:self.projectNum];
        [_projectNum release];
        
        self.strategyNum = [[UILabel alloc] init];
        self.strategyNum.textColor = [UIColor blueColor];
        [self.contentView addSubview:self.strategyNum];
        [_strategyNum release];
        
        self.photoNum = [[UILabel alloc] init];
        self.photoNum.textColor = [UIColor blueColor];
        [self.contentView addSubview:self.photoNum];
        [_photoNum release];
        
        self.firL = [[UILabel alloc] init];
        self.firL.text = @"案例:";
        [self.contentView addSubview:self.firL];
        [_firL release];
        
        self.secL = [[UILabel alloc] init];
        self.secL.text = @"攻略:";
        [self.contentView addSubview:self.secL];
        [_secL release];
        
        self.thiL = [[UILabel alloc] init];
        self.thiL.text = @"分享:";
        [self.contentView addSubview:self.thiL];
        [_thiL release];
        
        self.goldImg = [[UIImageView alloc] init];
        [self.contentView addSubview:self.goldImg];
        [self.goldImg sd_setImageWithURL:[NSURL URLWithString:@"http://m.guju.com.cn/release/pic/icon/attestation2.png"]];
        //self.goldImg.image = [UIImage imageNamed:@"iconfont-jinpairenzheng@2x"];
        [_goldImg release];
        
        self.btnImg = [[UIImageView alloc] init];
        [self.contentView addSubview:self.btnImg];
        self.btnImg.image = [UIImage imageNamed:@"iconfont-qianjin@2x"];
        [_btnImg release];
        //self.userImg.backgroundColor = [UIColor greenColor];
    }
    return self;
}
-(void)layoutSubviews
{
    //首先调用父类方法
    [super layoutSubviews];
    self.userImg.frame = CGRectMake(20, 20, 60, 60);
    self.userImg.layer.cornerRadius = self.userImg.frame.size.width/2;
    self.userImg.clipsToBounds = YES;
    /**
     *  label自适应宽度
     *
     *  @param size  行高上线
     *  @param 参数1 字体
     *
     *  @return 自适应size
     */
    CGSize size = CGSizeMake(320,2000);
    //CGSize labelSize = [self.name.text sizeWithFont:[UIFont systemFontOfSize:20] constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
    CGRect rect = [self.name.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]} context:nil];
    self.name.frame = CGRectMake(100, 10, rect.size.width,30);
    self.sex.frame = CGRectMake(self.name.frame.origin.x, self.name.frame.size.height + self.name.frame.origin.y, 35, 20);
    self.address.frame = CGRectMake(self.name.frame.origin.x +self.sex.frame.size.width, self.sex.frame.origin.y, 100, 20);
    self.firL.frame = CGRectMake(self.name.frame.origin.x, self.address.frame.origin.y +self.address.frame.size.height + 10, 40, 20);
    self.projectNum.frame = CGRectMake(self.name.frame.origin.x + self.firL.frame.size.width, self.firL.frame.origin.y, 30, 20);
    self.secL.frame = CGRectMake(self.projectNum.frame.origin.x + self.projectNum.frame.size.width + 10, self.firL.frame.origin.y, 40, 20);
    self.strategyNum.frame = CGRectMake(self.secL.frame.origin.x + self.secL.frame.size.width, self.firL.frame.origin.y, 20, 20);
    self.thiL.frame = CGRectMake(self.strategyNum.frame.origin.x + self.strategyNum.frame.size.width, self.firL.frame.origin.y, 40, 20);
    self.photoNum.frame = CGRectMake(self.thiL.frame.origin.x + self.thiL.frame.size.width, self.firL.frame.origin.y, 50, 20);
    self.goldImg.frame = CGRectMake(self.name.frame.origin.x + self.name.frame.size.width+10, 15, 20, 20);
    self.btnImg.frame = CGRectMake(SCREEN_WIDTH - 50, 35, 30, 30);
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
